const co = require('co');
const request = require('co-request');

const API = require('../config/API');
require('../resources/device/device.model');
const ApplicationModel = require('mongoose').model('Application');


const release = co.wrap(function* (deviceID) {
  yield ApplicationModel.releaseDevice(deviceID);
  yield request(`${API.releaseDevice}${deviceID}`);
  return true;
});

const device = {
  release,
};
module.exports = device;
